/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Anthares
 */
@Entity
@Table(name = "TRAD_CATEG")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TradCateg.findAll", query = "SELECT t FROM TradCateg t"),
    @NamedQuery(name = "TradCateg.findById", query = "SELECT t FROM TradCateg t WHERE t.tradCategPK.categId = :categId AND t.tradCategPK.langId = :langId"),
    @NamedQuery(name = "TradCateg.findByCategId", query = "SELECT t FROM TradCateg t WHERE t.tradCategPK.categId = :categId"),
    @NamedQuery(name = "TradCateg.findByLangId", query = "SELECT t FROM TradCateg t WHERE t.tradCategPK.langId = :langId"),
    @NamedQuery(name = "TradCateg.findByLibelle", query = "SELECT t FROM TradCateg t WHERE t.libelle = :libelle"),
    @NamedQuery(name = "TradCateg.findByDescrip", query = "SELECT t FROM TradCateg t WHERE t.descrip = :descrip")})
public class TradCateg implements Serializable {
    private static final long serialVersionUID = 1L;

    @EmbeddedId
    protected TradCategPK tradCategPK;

    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(nullable = false, length = 255)
    private String libelle;

    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(nullable = false, length = 255)
    private String descrip;

    @JoinColumn(name = "LANG_ID", referencedColumnName = "LANG_ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Langue langue;

    @JoinColumn(name = "CATEG_ID", referencedColumnName = "CATEG_ID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private CategProd categProd;

    public TradCateg() {
    }

    public TradCateg(TradCategPK tradCategPK) {
        this.tradCategPK = tradCategPK;
    }

    public TradCateg(TradCategPK tradCategPK, String libelle, String descrip) {
        this.tradCategPK = tradCategPK;
        this.libelle = libelle;
        this.descrip = descrip;
    }

    public TradCateg(int categId, String langId) {
        this.tradCategPK = new TradCategPK(categId, langId);
    }

    public TradCategPK getTradCategPK() {
        return tradCategPK;
    }

    public void setTradCategPK(TradCategPK tradCategPK) {
        this.tradCategPK = tradCategPK;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public String getDescrip() {
        return descrip;
    }

    public void setDescrip(String descrip) {
        this.descrip = descrip;
    }

    public Langue getLangue() {
        return langue;
    }

    public void setLangue(Langue langue) {
        this.langue = langue;
    }

    public CategProd getCategProd() {
        return categProd;
    }

    public void setCategProd(CategProd categProd) {
        this.categProd = categProd;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tradCategPK != null ? tradCategPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TradCateg)) {
            return false;
        }
        TradCateg other = (TradCateg) object;
        if ((this.tradCategPK == null && other.tradCategPK != null) || (this.tradCategPK != null && !this.tradCategPK.equals(other.tradCategPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Model.TradCateg[ tradCategPK=" + tradCategPK + " ]";
    }
    
}
